package pl.mmadej.ds4java.ds.list;


import java.util.Comparator;
import java.util.Iterator;

class UnmodifableList<T> implements List<T> {

    private List<T> delegator;

    UnmodifableList(List<T> delegator) {
        this.delegator = delegator;
    }

    @Override
    public int size() {
        return delegator.size();
    }

    public boolean contains(T element) {
        return delegator.contains(element);
    }

    public int indexOf(T element) {
        return delegator.indexOf(element);
    }

    public void insert(T element) {
        throw new UnsupportedOperationException();
    }

    public void insertAt(int index, T element) {
        throw new UnsupportedOperationException();
    }

    @Override
    public T searchAt(int index) {
        return delegator.searchAt(index);
    }

    @Override
    public T deleteAt(int index) {
        throw new UnsupportedOperationException();
    }

    public boolean delete(T element) {
        throw new UnsupportedOperationException();
    }

    @Override
    public T deleteLast() {
        throw new UnsupportedOperationException();
    }

    @Override
    public T deleteFirst() {
        throw new UnsupportedOperationException();
    }

    @Override
    public T searchLast() {
        return delegator.searchLast();
    }

    @Override
    public T searchFirst() {
        return delegator.searchFirst();
    }

    @Override
    public List<T> toUnmodifiable() {
        return this;
    }

    @Override
    public <E> E[] toArray(E[] e) {
        return delegator.toArray(e);
    }

    @Override
    public void sort(Comparator<T> comparator) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void clear() {
        throw new UnsupportedOperationException();
    }

    @Override
    public void reverse() {
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean empty() {
        return delegator.empty();
    }

    @Override
    public Iterator<T> iterator() {
        return new UnmodifiableIteratorAdapter<T>(delegator.iterator());
    }

    @Override
    public String toString() {
        return delegator.toString();
    }

    @Override
    public int hashCode() {
        return delegator.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        return delegator.equals(obj);
    }
}
